import { getInvasiveSpeciesList, getPlantQuarantine } from '@/api/agriculture.ts';
import type { pageItem } from '@/api/type/agriculture.ts';
import { defineDataSource } from '@/utils/pinia.ts';

export const useDefineDataSourceStore = defineStore('DefineDataSourceStore', () => {
  /**
   * 科普知识
   */
  const KnowledgeListReq = ref<pageItem>({
    pageNo: 1,
    pageSize: 10,
  });
  const KnowledgeList = defineDataSource<any>(
    {
      data: [],
      meta: {},
    },
    () => getInvasiveSpeciesList(KnowledgeListReq.value),
    {
      resetOnError: true,
    }
  );

  /**
   * 政策法规
   */
  const PolicyListReq = ref<pageItem>({
    pageNo: 1,
    pageSize: 10,
  });
  const PolicyList = defineDataSource<any>(
    {
      data: [],
      meta: {},
    },
    () => getPlantQuarantine(PolicyListReq.value),
    {
      resetOnError: true,
    }
  );

  return {
    KnowledgeListReq,
    KnowledgeList,
    PolicyListReq,
    PolicyList,
  };
});
